/**
 * 
 * ETH AI GAME LIBRARY
 * 
 * Author: Michael Jaworski
 * Copyright (c) Michael Jaworski 2010
 * http://code.google.com/p/eth/
 * 
 * Licence Agreement
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *	
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

package lib.eth.world.time
{
	import lib.eth.core.interfaces.IEthSystem;
	
	/**
	 * stores and creates the frame and real time for the system. if a class in the Eth
	 * libary requires this class, then make sure tha the fps is set. it will default 
	 * to 30fps, but if you change it you will need to update the value in this class.
	 * 
	 * @version 0.1
	 * 
	 */ 
	public final class EthTime implements IEthSystem
	{
		/**
		 * the default frame rate is 30 frames per second
		 */ 
		public static const DEFAULT_FPS:int = 30;
		
		/**
		 * track the number of frames progressed
		 */ 
		private var _frame:EthFrameTime;
		
		/**
		 * track the real time progressed
		 */ 
		private var _real:EthRealTime;
		
		/**
		 * track the frames per second
		 */ 
		private var _fps:int;		
		
		/**
		 * set the default FPS and creates both the frame and real time 
		 * objects
		 * 
		 */ 
		public function EthTime()
		{
			_fps = DEFAULT_FPS;
			
			_frame = new EthFrameTime ();
			_real = new EthRealTime ();
		}
		
		/**
		 * @see lib.eth.systems.world.time.EthFrameTime
		 */ 
		public final function get frame () : EthFrameTime
		{ return _frame; }
		
		/**
		 * @see lib.eth.systems.world.time.EthGameTime
		 */ 
		public final function get real () : EthRealTime
		{ return _real; }
		
		/**
		 * the fps only reflects what the user has set. it defaults to
		 * 30, but if it changes the user must change it
		 */ 
		public function get fps () : int												
		{	return _fps; }
		
		/**
		 * to set the fps to whatever the system is set to
		 */ 
		public function set fps (fpsIn:int) : void
		{ _fps = fpsIn; }		
		
		/**
		 * resets both the frame and real time classes
		 */ 
		public function reset () : void
		{
			_frame.reset ();
			_real.reset ();
		}
	}
}